package eg.com.itiga.ui.actions;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import eg.com.itiga.business.base.BaseService;
import eg.com.itiga.business.factory.BusinessFactory;
import eg.com.itiga.business.role.RoleService;
import eg.com.itiga.domain.CompanyField;
import eg.com.itiga.domain.ContactDetails;
import eg.com.itiga.domain.Field;
import eg.com.itiga.domain.RegCompany;
import eg.com.itiga.domain.Role;
import eg.com.itiga.domain.User;
import eg.com.itiga.ui.beans.ManageCompanyActionForm;
import eg.com.itiga.ui.beans.RequestRegistrationForm;

public class RequestRegistrationAction extends org.apache.struts.action.Action {
    


    
    public RequestRegistrationAction() {
    }
    
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        // TODO: Write method body
    	RequestRegistrationForm frm = (RequestRegistrationForm)form;
    	
    	
    	//RoleService roleService = BusinessFactory.createRoleService();
        //Role companyRole = roleService.getRoleByName("Company");
        
        BaseService baseService = BusinessFactory.createBaseService();
    	
        
    	
    	RegCompany regCompany = new RegCompany();
    	regCompany.setCName(frm.getCName());
    	regCompany.setRegWesite(frm.getCWebsite());
    	// ************* this should be Integer not Date ***************
    	//regCompany.setRegExpDate(new Date());
    	regCompany.setCState(RegCompany.REQUESTED);
    	regCompany.setIsRegIsApproved(false);
    	
    	
    	
        baseService.add(regCompany);
        System.out.println("Company request registration successfully...");
        ActionForward forward=mapping.findForward("companyRequestIsSent");
        return forward;
    }

}